﻿
<?php
	include("php/session.php");
	include("php/bbcode.php");
	include("dao/CategoriasDAO.class.php");
	include("dao/ConteudoDAO.class.php");
?>

<?php	
	
	#$idcategoria_get = $_GET['append'];
	#$categoria_get = $_GET['match'];
	
	$categoriasdao = new CategoriasDAO();
	$categorias = $categoriasdao->buscar();
	
?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Chimera</title>
<link rel="stylesheet" type="text/css" href="css/css.css">
<link rel="stylesheet" type="text/css" href="css/prettify.css">
<script src="js/run_prettify.js"></script>
<script src="js/jquery-1.11.1.js"></script>
<script src="js/campos.js"></script>

<script>
	$(document).ready(function(e) {
        $("textarea").keydown(function(e) {
			if(e.keyCode === 9) { // tab was pressed
				// get caret position/selection
				var start = this.selectionStart;
					end = this.selectionEnd;
		
				var $this = $(this);
		
				// set textarea value to: text before caret + tab + text after caret
				$this.val($this.val().substring(0, start)
							+ "\t"
							+ $this.val().substring(end));
		
				// put caret at right position again
				this.selectionStart = this.selectionEnd = start + 1;
		
				// prevent the focus lose
				return false;
			}
		});
    });
</script>

</head>

<body>
	<main>
   	  
      <header>
          <div class="container">
              <a href="inicio.php"><span class="logo"></span></a>
              <input type="text" class="pesquisaTopo" placeholder="Faça sua pesquisa..." />
              <select class="categoriasPesquisa">
                  <?php foreach($categorias as $categoria): ?>
                      <option value="<?= $categoria->getIdCategorias();?>"><?= $categoria->getNome();?></option>
                  <?php endforeach;?>
              </select>
              <span class="logout">
                  <a href="php/logout.php">sair</a>
              </span>
              <span class="sessionNome"><?= $_SESSION['nome'] ?></span>
          </div>
      </header>
      
      <section class="novo">
      
      	<div class="subMenuToolbar">
            <div class="container">
                <h1 style="float:left !important;">Novo post para <?= $categoria_get?></h1>
            </div>
        </div>
        
        <div class="container">
            
            <div class="junteLeft">
                <h3 class="menuTitulo">Vamos pra outra ?</h3>
                <ul class="menu">
     
                    <?php foreach($categorias as $categoria): ?>
                    
                        <li>
                            <a href="posts.php?append=<?= $categoria->getIdCategorias();?>&match=<?= $categoria->getNome();?>">
                                <?= $categoria->getNome();?>
                            </a>
                        </li>
                    
                    <?php endforeach;?>
                
                </ul>
            </div>
            
            <div class="junteRight">
            	<h3 class="menuTitulo">Publique algo em <?= $categoria_get?></h3>
            	<form class="formNovaNew" 
                action="controller/add.php?append=<?= $idcategoria_get?>&match=<?= $categoria_get?>&action=3445" method="post">
                	
                    <input type="text" class="inputAssunto" placeholder="Assunto" name="assunto"/>
                    <textarea id="mybox" class="inputConteudo" placeholder="Escreva o texto aqui" name="conteudo"></textarea>
                    
                    <a href="#" class="adicionarCampo">+</a>
                    
                    <div class="divTags">
                    	<input class="inputTags" name="tags[]" placeholder="Insira tags para pesquisa..."/>
                    </div>
                    
                    <input class="buttonEnviar" type="submit" value="Enviar" />
                    
                </form>
            </div>
            
        </div>
      
      </section>
      
    </main>
</body>
</html>